<template>
	<view class="page">
		<view v-if="formData.id !=''">
			<view class="info-content">
				<view class="u-flex u-title-line">
					<text class="name">{{formData.name}}</text>
					<text class="birthday">{{formData.birthDate}}</text>
					<text class="origin">{{formData.origin}}</text>
				</view>
				<view class="info-line">
					<label>定居年数</label><text>{{formData.yearsOfResidence}}年</text>
				</view>
				<view class="info-line">
					<label>学历</label><text>{{formData.education}}</text>
				</view>

				<view class="info-line">
					<label>与法人关系说明</label><text>{{formData.relationshipBetweenActualControllerAndLegalRepresentative}}</text>
				</view>
				<view class="info-line">
					<label>两年内是否变更</label><text>{{formData.hasActualControllerChangedInTwoYears?"是":"否"}}</text>
				</view>
				<view class="info-line" style="display: flex; flex-direction: column;">
					<label>附件信息</label>
					<JSGJImages :imagesList="formData.attendanceFileList"></JSGJImages>
				</view>
			</view>
			<u-gap height="20" bg-color="#f0f2f6"></u-gap>
			<sign-uplpad :customerId="customerId" :businessId="formData.businessId" title="婚姻情况" type="actualMarry"
				v-if="showUpload" @refresh="refresh"></sign-uplpad>
			<u-gap height="20" bg-color="#f0f2f6"></u-gap>
			<sign-uplpad :customerId="customerId" :businessId="formData.businessId" title="子女情况" type="actualChildren"
				v-if="showUpload" @refresh="refresh"></sign-uplpad>
			<u-gap height="20" bg-color="#f0f2f6"></u-gap>
			<sign-uplpad :customerId="customerId" :businessId="formData.businessId" title="家庭成员本地定居情况"
				type="actualLocalLife" v-if="showUpload" @refresh="refresh"></sign-uplpad>
			<u-gap height="20" bg-color="#f0f2f6"></u-gap>
			<sign-uplpad :customerId="customerId" :businessId="formData.businessId" title="专业技能或个人荣誉" type="personSkill"
				v-if="showUpload" @refresh="refresh"></sign-uplpad>
			<u-gap height="20" bg-color="#f0f2f6"></u-gap>
			<sign-uplpad :customerId="customerId" :businessId="formData.businessId" title="现场访谈" type="talkInfo"
				v-if="showUpload" @refresh="refresh"></sign-uplpad>
			<u-gap height="20" bg-color="#f0f2f6"></u-gap>
			<actual-flowwater :customerId="customerId"></actual-flowwater>
			<actual-work :customerId="customerId"></actual-work>
			<actual-house :customerId="customerId"></actual-house>
			<actual-vchicle :customerId="customerId"></actual-vchicle>
		</view>
		<view v-else class="no-data-text">
			<view class="explain uni-center">
				暂无实际控制人信息
			</view>
		</view>
		<view class="save-bottom" v-if="showBtn">
			<view class="fixed-btn save-padding">
				<u-button type="primary" shape="circle"
					@click="$helper.onJump(`/pagesJiushi/customer/actualController/actualController?id=${formData.id}&cid=${customerId}`)">{{formData.id?'编辑':'新增'}}实际控制人</u-button>
			</view>
		</view>
	</view>
</template>

<script>
	import config from '@/common/js/config.js';
	import dateTime from '@/components/dateTime/dateTime.vue'
	import jnpf from '@/common/js/jnpf.js'
	import signUplpad from './signUplpad.vue'
	import actualFlowwater from './actualFlowwater.vue'
	import actualHouse from './actualHouse.vue'
	import actualVchicle from './actualVchicle.vue'
	import actualWork from './actualWork.vue'
	export default {
		components: {
			dateTime,
			signUplpad,
			actualFlowwater,
			actualHouse,
			actualVchicle,
			actualWork
		},
		name: 'customerBase',
		props: {
			customerId: {
				type: [Number, String],
				default () {
					return ''
				}
			}
		},
		created() {
			this.showBtn = uni.getStorageSync(config.Global.cache + '_ShowCompanyButton')
			if (!this.showBtn) {
				this.options = []
			}
		},
		data() {
			return {
				showBtn: false,
				formData: {
					id: '',
					customerId: undefined,
					name: undefined,
					birthDate: undefined,
					education: undefined,
					origin: undefined,
					marriageStatus: undefined,
					spouseSituation: undefined,
					yearsOfResidence: undefined,
					childrenSituation: undefined,
					familyLocalResidenceStatus: undefined,
					familyPropertyInformation: undefined,
					professionalSkillsOrHonors: undefined,
					relationshipBetweenActualControllerAndLegalRepresentative: undefined,
					hasActualControllerChangedInTwoYears: undefined,
				},
				dictionaryData: jnpf.dictionaryData('Education'),
				showUpload: true,
			};
		},
		watch: {
			customerId: {
				immediate: true,
				deep: true,
				handler(val) {
					this.formData.customerId = val
					this.getFormData()
				}
			}
		},
		methods: {
			refresh() {
				this.showUpload = false
				this.$nextTick(() => {
					this.showUpload = true;
				});
			},
			getFormData() {
				this.$helper.ajax({
					url: "/api/Jiushi/Customeractualcontroller?customerId=" + this.customerId,
					method: "GET",
					contentType: "application/json",
					success: res => {
						if (res.data.data) {
							if (res.data.data.list.length > 0) {
								this.formData = res.data.data.list[0]
								if (this.formData.professionalSkillsOrHonors != "" && this.formData
									.professionalSkillsOrHonors !=
									null) {
									this.formData.attendanceFileList = this.formData.professionalSkillsOrHonors
										.split(',')
								}
							}
						}
					}
				});
			}
		}
	}
</script>
<style scoped lang="scss">
	.u-title-line {
		.name {
			font-size: 30rpx;
		}

		.birthday {
			box-sizing: content-box;
			border: 1rpx solid #3d66ff;
			color: #3d66ff;
			padding: 2rpx 10rpx;
			line-height: 1;
			font-size: 24rpx;
			margin: 0 20rpx;
			border-radius: 6rpx;
		}

		.origin {
			border: 1rpx solid #fd7108;
			color: #fd7108;
			font-size: 24rpx;
			padding: 2rpx 10rpx;
			line-height: 1;
			border-radius: 6rpx;
		}
	}
</style>